from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import AdaBoostClassifier         #Ada提升分类器
from sklearn.tree import DecisionTreeClassifier
from sklearn import datasets

dataset_all = datasets.load_breast_cancer()             #乳腺癌数据集
X = dataset_all.data
Y = dataset_all.target

kfold = KFold(n_splits=10, shuffle=True, random_state=42)
dtree = DecisionTreeClassifier(max_depth=3)
dtree = dtree.fit(X, Y)

result = cross_val_score(dtree, X, Y, cv=kfold)
print("决策树结果： ",result.mean())

model = AdaBoostClassifier(base_estimator=dtree, n_estimators=100,random_state=42)
result = cross_val_score(model, X, Y, cv=kfold)
print("提升法改进结果： ",result.mean())


